package com.zhu.storesmanager.models;

import java.text.DecimalFormat;

import com.zhu.storesmanager.utils.Actions;

import android.content.Context;

/**
 * 品牌数据
 */
public class BrandsDataItem {
	public String mBrandId; // 品牌ID
	public String mBrandName; // 品牌名字
	public int mSellCount; // 销售台数
	public int mSellMoney; // 销售金额
	public int mAllSellCount; // 总销量台数
	public int mAllSellMoney; // 总销售金额

	/**
	 * 获取销售台数文本
	 */
	public String getSellCountText() {
		return mSellCount + "";
	}

	/**
	 * 获取销售金额文本
	 */
	public String getSellMoneyText() {
		return mSellMoney + "";
	}

	/**
	 * 获取销量数量比例
	 */
	public String getSellCountPercent() {
		return Actions.getPercent(mSellCount, mAllSellCount);
	}

	/**
	 * 获取销量金额比例
	 */
	public String getSellMoneyPercent() {
		return Actions.getPercent(mSellMoney, mAllSellMoney);
	}

	/**
	 *获取保存的数据
	 *@param  split 分割符号
	 */
	public String getSavedData(String split){
	    return mBrandId + split + mBrandName + split + mSellCount + split +
	    mSellMoney + split + mAllSellCount + split + mAllSellMoney + split;
	}

	/**
	 * 设置数据
	 * @param brand 品牌数据
	 * @param split 分割符号
	 * @return ture 设置成功 否则反之
	 */
	public boolean setBrandData(String brand, String split){
	    if(brand != null && brand.length() > 0){
	        String[] branchArr = brand.split(split);
	        mBrandId = branchArr[0];
	        mBrandName = branchArr[1];
	        mSellCount = Integer.parseInt(branchArr[2]);
	        mSellMoney = Integer.parseInt(branchArr[3]);
	        mAllSellCount = Integer.parseInt(branchArr[4]);
	        mAllSellMoney = Integer.parseInt(branchArr[5]);
	        return true;
	    }
	    return false;
	}
}
